//
//  ZCInvolvedModel.m
//
//  Created by   on 15/12/31
//  Copyright (c) 2015 __MyCompanyName__. All rights reserved.
//

#import "ZCInvolvedModel.h"


NSString *const kZCInvolvedModelCtime = @"ctime";
NSString *const kZCInvolvedModelEmoney = @"emoney";
NSString *const kZCInvolvedModelLogo = @"logo";
NSString *const kZCInvolvedModelId = @"id";
NSString *const kZCInvolvedModelState = @"state";
NSString *const kZCInvolvedModelTestreportid = @"testreportid";
NSString *const kZCInvolvedModelRank = @"rank";
NSString *const kZCInvolvedModelLocation = @"location";
NSString *const kZCInvolvedModelBtime = @"btime";
NSString *const kZCInvolvedModelThumb = @"thumb";
NSString *const kZCInvolvedModelFirstCategoryid = @"first_categoryid";
NSString *const kZCInvolvedModelPackagename = @"packagename";
NSString *const kZCInvolvedModelBrand = @"brand";
NSString *const kZCInvolvedModelSampleid = @"sampleid";
NSString *const kZCInvolvedModelBatch = @"batch";
NSString *const kZCInvolvedModelTestingDate = @"testing_date";
NSString *const kZCInvolvedModelEtime = @"etime";
NSString *const kZCInvolvedModelUsername = @"username";
NSString *const kZCInvolvedModelSecondCategoryid = @"second_categoryid";
NSString *const kZCInvolvedModelRawdata = @"rawdata";
NSString *const kZCInvolvedModelInstitutionid = @"institutionid";
NSString *const kZCInvolvedModelPackageid = @"packageid";
NSString *const kZCInvolvedModelPdname = @"pdname";
NSString *const kZCInvolvedModelPjname = @"pjname";
NSString *const kZCInvolvedModelSamnum = @"samnum";
NSString *const kZCInvolvedModelInstitution = @"institution";
NSString *const kZCInvolvedModelAvatar = @"avatar";
NSString *const kZCInvolvedModelSponsorsCount = @"sponsors_count";
NSString *const kZCInvolvedModelMid = @"mid";
NSString *const kZCInvolvedModelResult = @"result";
NSString *const kZCInvolvedModelContent = @"content";
NSString *const kZCInvolvedModelSmoney = @"smoney";
NSString *const kZCInvolvedModelFinish = @"finish";
NSString *const kZCInvolvedModelWxMediaIds = @"wx_media_ids";
NSString *const kZCInvolvedModelCitycode = @"citycode";
NSString *const kZCInvolvedModelFromtype = @"fromtype";
NSString *const kZCInvolvedModelMemberUploadImgs = @"member_upload_imgs";
NSString *const kZCInvolvedModelMiniThumb = @"mini_thumb";
NSString *const kZCInvolvedModelPid = @"pid";
NSString *const kZCInvolvedModelTestingResult = @"testing_result";



@interface ZCInvolvedModel ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation ZCInvolvedModel

@synthesize ctime = _ctime;
@synthesize emoney = _emoney;
@synthesize logo = _logo;
@synthesize internalBaseClassIdentifier = _internalBaseClassIdentifier;
@synthesize state = _state;
@synthesize testreportid = _testreportid;
@synthesize rank = _rank;
@synthesize location = _location;
@synthesize btime = _btime;
@synthesize thumb = _thumb;
@synthesize firstCategoryid = _firstCategoryid;
@synthesize packagename = _packagename;
@synthesize brand = _brand;
@synthesize sampleid = _sampleid;
@synthesize batch = _batch;
@synthesize testingDate = _testingDate;
@synthesize etime = _etime;
@synthesize username = _username;
@synthesize secondCategoryid = _secondCategoryid;
@synthesize rawdata = _rawdata;
@synthesize institutionid = _institutionid;
@synthesize packageid = _packageid;
@synthesize pdname = _pdname;
@synthesize pjname = _pjname;
@synthesize samnum = _samnum;
@synthesize institution = _institution;
@synthesize avatar = _avatar;
@synthesize sponsorsCount = _sponsorsCount;
@synthesize mid = _mid;
@synthesize result = _result;
@synthesize content = _content;
@synthesize smoney = _smoney;
@synthesize finish = _finish;
@synthesize wxMediaIds = _wxMediaIds;
@synthesize citycode = _citycode;
@synthesize fromtype = _fromtype;
@synthesize memberUploadImgs = _memberUploadImgs;
@synthesize miniThumb = _miniThumb;
@synthesize pid = _pid;
@synthesize testing_result = _testing_result;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.ctime = [self objectOrNilForKey:kZCInvolvedModelCtime fromDictionary:dict];
            self.emoney = [[self objectOrNilForKey:kZCInvolvedModelEmoney fromDictionary:dict] doubleValue];
            self.logo = [self objectOrNilForKey:kZCInvolvedModelLogo fromDictionary:dict];
            self.internalBaseClassIdentifier = [self objectOrNilForKey:kZCInvolvedModelId fromDictionary:dict];
            self.state = [self objectOrNilForKey:kZCInvolvedModelState fromDictionary:dict];
            self.testreportid = [self objectOrNilForKey:kZCInvolvedModelTestreportid fromDictionary:dict];
            self.rank = [self objectOrNilForKey:kZCInvolvedModelRank fromDictionary:dict];
            self.location = [self objectOrNilForKey:kZCInvolvedModelLocation fromDictionary:dict];
            self.btime = [self objectOrNilForKey:kZCInvolvedModelBtime fromDictionary:dict];
            self.thumb = [self objectOrNilForKey:kZCInvolvedModelThumb fromDictionary:dict];
            self.firstCategoryid = [self objectOrNilForKey:kZCInvolvedModelFirstCategoryid fromDictionary:dict];
            self.packagename = [self objectOrNilForKey:kZCInvolvedModelPackagename fromDictionary:dict];
            self.brand = [self objectOrNilForKey:kZCInvolvedModelBrand fromDictionary:dict];
            self.sampleid = [self objectOrNilForKey:kZCInvolvedModelSampleid fromDictionary:dict];
            self.batch = [self objectOrNilForKey:kZCInvolvedModelBatch fromDictionary:dict];
            self.testingDate = [self objectOrNilForKey:kZCInvolvedModelTestingDate fromDictionary:dict];
            self.etime = [self objectOrNilForKey:kZCInvolvedModelEtime fromDictionary:dict];
            self.username = [self objectOrNilForKey:kZCInvolvedModelUsername fromDictionary:dict];
            self.secondCategoryid = [self objectOrNilForKey:kZCInvolvedModelSecondCategoryid fromDictionary:dict];
            self.rawdata = [self objectOrNilForKey:kZCInvolvedModelRawdata fromDictionary:dict];
            self.institutionid = [self objectOrNilForKey:kZCInvolvedModelInstitutionid fromDictionary:dict];
            self.packageid = [self objectOrNilForKey:kZCInvolvedModelPackageid fromDictionary:dict];
            self.pdname = [self objectOrNilForKey:kZCInvolvedModelPdname fromDictionary:dict];
            self.pjname = [self objectOrNilForKey:kZCInvolvedModelPjname fromDictionary:dict];
            self.samnum = [self objectOrNilForKey:kZCInvolvedModelSamnum fromDictionary:dict];
            self.institution = [self objectOrNilForKey:kZCInvolvedModelInstitution fromDictionary:dict];
            self.avatar = [self objectOrNilForKey:kZCInvolvedModelAvatar fromDictionary:dict];
            self.sponsorsCount = [self objectOrNilForKey:kZCInvolvedModelSponsorsCount fromDictionary:dict];
            self.mid = [self objectOrNilForKey:kZCInvolvedModelMid fromDictionary:dict];
            self.result = [self objectOrNilForKey:kZCInvolvedModelResult fromDictionary:dict];
            self.content = [self objectOrNilForKey:kZCInvolvedModelContent fromDictionary:dict];
            self.smoney = [self objectOrNilForKey:kZCInvolvedModelSmoney fromDictionary:dict];
            self.finish = [self objectOrNilForKey:kZCInvolvedModelFinish fromDictionary:dict];
            self.wxMediaIds = [self objectOrNilForKey:kZCInvolvedModelWxMediaIds fromDictionary:dict];
            self.citycode = [self objectOrNilForKey:kZCInvolvedModelCitycode fromDictionary:dict];
            self.fromtype = [self objectOrNilForKey:kZCInvolvedModelFromtype fromDictionary:dict];
            self.memberUploadImgs = [self objectOrNilForKey:kZCInvolvedModelMemberUploadImgs fromDictionary:dict];
            self.miniThumb = [self objectOrNilForKey:kZCInvolvedModelMiniThumb fromDictionary:dict];
            self.pid = [self objectOrNilForKey:kZCInvolvedModelPid fromDictionary:dict];
            self.testing_result = [self objectOrNilForKey:kZCInvolvedModelTestingResult fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.ctime forKey:kZCInvolvedModelCtime];
    [mutableDict setValue:[NSNumber numberWithDouble:self.emoney] forKey:kZCInvolvedModelEmoney];
    [mutableDict setValue:self.logo forKey:kZCInvolvedModelLogo];
    [mutableDict setValue:self.internalBaseClassIdentifier forKey:kZCInvolvedModelId];
    [mutableDict setValue:self.state forKey:kZCInvolvedModelState];
    [mutableDict setValue:self.testreportid forKey:kZCInvolvedModelTestreportid];
    [mutableDict setValue:self.rank forKey:kZCInvolvedModelRank];
    [mutableDict setValue:self.location forKey:kZCInvolvedModelLocation];
    [mutableDict setValue:self.btime forKey:kZCInvolvedModelBtime];
    [mutableDict setValue:self.thumb forKey:kZCInvolvedModelThumb];
    [mutableDict setValue:self.firstCategoryid forKey:kZCInvolvedModelFirstCategoryid];
    [mutableDict setValue:self.packagename forKey:kZCInvolvedModelPackagename];
    [mutableDict setValue:self.brand forKey:kZCInvolvedModelBrand];
    [mutableDict setValue:self.sampleid forKey:kZCInvolvedModelSampleid];
    [mutableDict setValue:self.batch forKey:kZCInvolvedModelBatch];
    [mutableDict setValue:self.testingDate forKey:kZCInvolvedModelTestingDate];
    [mutableDict setValue:self.etime forKey:kZCInvolvedModelEtime];
    [mutableDict setValue:self.username forKey:kZCInvolvedModelUsername];
    [mutableDict setValue:self.secondCategoryid forKey:kZCInvolvedModelSecondCategoryid];
    [mutableDict setValue:self.rawdata forKey:kZCInvolvedModelRawdata];
    [mutableDict setValue:self.institutionid forKey:kZCInvolvedModelInstitutionid];
    [mutableDict setValue:self.packageid forKey:kZCInvolvedModelPackageid];
    [mutableDict setValue:self.pdname forKey:kZCInvolvedModelPdname];
    [mutableDict setValue:self.pjname forKey:kZCInvolvedModelPjname];
    [mutableDict setValue:self.samnum forKey:kZCInvolvedModelSamnum];
    [mutableDict setValue:self.institution forKey:kZCInvolvedModelInstitution];
    [mutableDict setValue:self.avatar forKey:kZCInvolvedModelAvatar];
    [mutableDict setValue:self.sponsorsCount forKey:kZCInvolvedModelSponsorsCount];
    [mutableDict setValue:self.mid forKey:kZCInvolvedModelMid];
    [mutableDict setValue:self.result forKey:kZCInvolvedModelResult];
    [mutableDict setValue:self.content forKey:kZCInvolvedModelContent];
    [mutableDict setValue:self.smoney forKey:kZCInvolvedModelSmoney];
    [mutableDict setValue:self.finish forKey:kZCInvolvedModelFinish];
    [mutableDict setValue:self.wxMediaIds forKey:kZCInvolvedModelWxMediaIds];
    [mutableDict setValue:self.citycode forKey:kZCInvolvedModelCitycode];
    [mutableDict setValue:self.fromtype forKey:kZCInvolvedModelFromtype];
    [mutableDict setValue:self.memberUploadImgs forKey:kZCInvolvedModelMemberUploadImgs];
    [mutableDict setValue:self.miniThumb forKey:kZCInvolvedModelMiniThumb];
    [mutableDict setValue:self.pid forKey:kZCInvolvedModelPid];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.ctime = [aDecoder decodeObjectForKey:kZCInvolvedModelCtime];
    self.emoney = [aDecoder decodeDoubleForKey:kZCInvolvedModelEmoney];
    self.logo = [aDecoder decodeObjectForKey:kZCInvolvedModelLogo];
    self.internalBaseClassIdentifier = [aDecoder decodeObjectForKey:kZCInvolvedModelId];
    self.state = [aDecoder decodeObjectForKey:kZCInvolvedModelState];
    self.testreportid = [aDecoder decodeObjectForKey:kZCInvolvedModelTestreportid];
    self.rank = [aDecoder decodeObjectForKey:kZCInvolvedModelRank];
    self.location = [aDecoder decodeObjectForKey:kZCInvolvedModelLocation];
    self.btime = [aDecoder decodeObjectForKey:kZCInvolvedModelBtime];
    self.thumb = [aDecoder decodeObjectForKey:kZCInvolvedModelThumb];
    self.firstCategoryid = [aDecoder decodeObjectForKey:kZCInvolvedModelFirstCategoryid];
    self.packagename = [aDecoder decodeObjectForKey:kZCInvolvedModelPackagename];
    self.brand = [aDecoder decodeObjectForKey:kZCInvolvedModelBrand];
    self.sampleid = [aDecoder decodeObjectForKey:kZCInvolvedModelSampleid];
    self.batch = [aDecoder decodeObjectForKey:kZCInvolvedModelBatch];
    self.testingDate = [aDecoder decodeObjectForKey:kZCInvolvedModelTestingDate];
    self.etime = [aDecoder decodeObjectForKey:kZCInvolvedModelEtime];
    self.username = [aDecoder decodeObjectForKey:kZCInvolvedModelUsername];
    self.secondCategoryid = [aDecoder decodeObjectForKey:kZCInvolvedModelSecondCategoryid];
    self.rawdata = [aDecoder decodeObjectForKey:kZCInvolvedModelRawdata];
    self.institutionid = [aDecoder decodeObjectForKey:kZCInvolvedModelInstitutionid];
    self.packageid = [aDecoder decodeObjectForKey:kZCInvolvedModelPackageid];
    self.pdname = [aDecoder decodeObjectForKey:kZCInvolvedModelPdname];
    self.pjname = [aDecoder decodeObjectForKey:kZCInvolvedModelPjname];
    self.samnum = [aDecoder decodeObjectForKey:kZCInvolvedModelSamnum];
    self.institution = [aDecoder decodeObjectForKey:kZCInvolvedModelInstitution];
    self.avatar = [aDecoder decodeObjectForKey:kZCInvolvedModelAvatar];
    self.sponsorsCount = [aDecoder decodeObjectForKey:kZCInvolvedModelSponsorsCount];
    self.mid = [aDecoder decodeObjectForKey:kZCInvolvedModelMid];
    self.result = [aDecoder decodeObjectForKey:kZCInvolvedModelResult];
    self.content = [aDecoder decodeObjectForKey:kZCInvolvedModelContent];
    self.smoney = [aDecoder decodeObjectForKey:kZCInvolvedModelSmoney];
    self.finish = [aDecoder decodeObjectForKey:kZCInvolvedModelFinish];
    self.wxMediaIds = [aDecoder decodeObjectForKey:kZCInvolvedModelWxMediaIds];
    self.citycode = [aDecoder decodeObjectForKey:kZCInvolvedModelCitycode];
    self.fromtype = [aDecoder decodeObjectForKey:kZCInvolvedModelFromtype];
    self.memberUploadImgs = [aDecoder decodeObjectForKey:kZCInvolvedModelMemberUploadImgs];
    self.miniThumb = [aDecoder decodeObjectForKey:kZCInvolvedModelMiniThumb];
    self.pid = [aDecoder decodeObjectForKey:kZCInvolvedModelPid];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_ctime forKey:kZCInvolvedModelCtime];
    [aCoder encodeDouble:_emoney forKey:kZCInvolvedModelEmoney];
    [aCoder encodeObject:_logo forKey:kZCInvolvedModelLogo];
    [aCoder encodeObject:_internalBaseClassIdentifier forKey:kZCInvolvedModelId];
    [aCoder encodeObject:_state forKey:kZCInvolvedModelState];
    [aCoder encodeObject:_testreportid forKey:kZCInvolvedModelTestreportid];
    [aCoder encodeObject:_rank forKey:kZCInvolvedModelRank];
    [aCoder encodeObject:_location forKey:kZCInvolvedModelLocation];
    [aCoder encodeObject:_btime forKey:kZCInvolvedModelBtime];
    [aCoder encodeObject:_thumb forKey:kZCInvolvedModelThumb];
    [aCoder encodeObject:_firstCategoryid forKey:kZCInvolvedModelFirstCategoryid];
    [aCoder encodeObject:_packagename forKey:kZCInvolvedModelPackagename];
    [aCoder encodeObject:_brand forKey:kZCInvolvedModelBrand];
    [aCoder encodeObject:_sampleid forKey:kZCInvolvedModelSampleid];
    [aCoder encodeObject:_batch forKey:kZCInvolvedModelBatch];
    [aCoder encodeObject:_testingDate forKey:kZCInvolvedModelTestingDate];
    [aCoder encodeObject:_etime forKey:kZCInvolvedModelEtime];
    [aCoder encodeObject:_username forKey:kZCInvolvedModelUsername];
    [aCoder encodeObject:_secondCategoryid forKey:kZCInvolvedModelSecondCategoryid];
    [aCoder encodeObject:_rawdata forKey:kZCInvolvedModelRawdata];
    [aCoder encodeObject:_institutionid forKey:kZCInvolvedModelInstitutionid];
    [aCoder encodeObject:_packageid forKey:kZCInvolvedModelPackageid];
    [aCoder encodeObject:_pdname forKey:kZCInvolvedModelPdname];
    [aCoder encodeObject:_pjname forKey:kZCInvolvedModelPjname];
    [aCoder encodeObject:_samnum forKey:kZCInvolvedModelSamnum];
    [aCoder encodeObject:_institution forKey:kZCInvolvedModelInstitution];
    [aCoder encodeObject:_avatar forKey:kZCInvolvedModelAvatar];
    [aCoder encodeObject:_sponsorsCount forKey:kZCInvolvedModelSponsorsCount];
    [aCoder encodeObject:_mid forKey:kZCInvolvedModelMid];
    [aCoder encodeObject:_result forKey:kZCInvolvedModelResult];
    [aCoder encodeObject:_content forKey:kZCInvolvedModelContent];
    [aCoder encodeObject:_smoney forKey:kZCInvolvedModelSmoney];
    [aCoder encodeObject:_finish forKey:kZCInvolvedModelFinish];
    [aCoder encodeObject:_wxMediaIds forKey:kZCInvolvedModelWxMediaIds];
    [aCoder encodeObject:_citycode forKey:kZCInvolvedModelCitycode];
    [aCoder encodeObject:_fromtype forKey:kZCInvolvedModelFromtype];
    [aCoder encodeObject:_memberUploadImgs forKey:kZCInvolvedModelMemberUploadImgs];
    [aCoder encodeObject:_miniThumb forKey:kZCInvolvedModelMiniThumb];
    [aCoder encodeObject:_pid forKey:kZCInvolvedModelPid];
}

- (id)copyWithZone:(NSZone *)zone
{
    ZCInvolvedModel *copy = [[ZCInvolvedModel alloc] init];
    
    if (copy) {

        copy.ctime = [self.ctime copyWithZone:zone];
        copy.emoney = self.emoney;
        copy.logo = [self.logo copyWithZone:zone];
        copy.internalBaseClassIdentifier = [self.internalBaseClassIdentifier copyWithZone:zone];
        copy.state = [self.state copyWithZone:zone];
        copy.testreportid = [self.testreportid copyWithZone:zone];
        copy.rank = [self.rank copyWithZone:zone];
        copy.location = [self.location copyWithZone:zone];
        copy.btime = [self.btime copyWithZone:zone];
        copy.thumb = [self.thumb copyWithZone:zone];
        copy.firstCategoryid = [self.firstCategoryid copyWithZone:zone];
        copy.packagename = [self.packagename copyWithZone:zone];
        copy.brand = [self.brand copyWithZone:zone];
        copy.sampleid = [self.sampleid copyWithZone:zone];
        copy.batch = [self.batch copyWithZone:zone];
        copy.testingDate = [self.testingDate copyWithZone:zone];
        copy.etime = [self.etime copyWithZone:zone];
        copy.username = [self.username copyWithZone:zone];
        copy.secondCategoryid = [self.secondCategoryid copyWithZone:zone];
        copy.rawdata = [self.rawdata copyWithZone:zone];
        copy.institutionid = [self.institutionid copyWithZone:zone];
        copy.packageid = [self.packageid copyWithZone:zone];
        copy.pdname = [self.pdname copyWithZone:zone];
        copy.pjname = [self.pjname copyWithZone:zone];
        copy.samnum = [self.samnum copyWithZone:zone];
        copy.institution = [self.institution copyWithZone:zone];
        copy.avatar = [self.avatar copyWithZone:zone];
        copy.sponsorsCount = [self.sponsorsCount copyWithZone:zone];
        copy.mid = [self.mid copyWithZone:zone];
        copy.result = [self.result copyWithZone:zone];
        copy.content = [self.content copyWithZone:zone];
        copy.smoney = [self.smoney copyWithZone:zone];
        copy.finish = [self.finish copyWithZone:zone];
        copy.wxMediaIds = [self.wxMediaIds copyWithZone:zone];
        copy.citycode = [self.citycode copyWithZone:zone];
        copy.fromtype = [self.fromtype copyWithZone:zone];
        copy.memberUploadImgs = [self.memberUploadImgs copyWithZone:zone];
        copy.miniThumb = [self.miniThumb copyWithZone:zone];
        copy.pid = [self.pid copyWithZone:zone];
    }
    
    return copy;
}


@end
